package richbar.com.richbar.activity.me.myassets;

import android.widget.TextView;

import com.common.base.BaseActivity;
import com.common.util.ToastUtil;
import com.okhttp.network.HttpUtils;
import com.okhttp.network.MyGson;

import butterknife.BindView;
import butterknife.ButterKnife;
import richbar.com.richbar.R;
import richbar.com.richbar.bean.IntegralBean;
import richbar.com.richbar.bean.P;
import richbar.com.richbar.bean.RebateBean;
import richbar.com.richbar.util.LoadingDialog;
import richbar.com.richbar.util.NetWorkUtil;

/**
 * Created by Administrator on 2018/11/29.
 * 积分账户
 */

public class IntegralAccountAc extends BaseActivity {
    private LoadingDialog dialog;
    @BindView(R.id.tv_1)
    TextView tv_1;
    @BindView(R.id.tv_2)
    TextView tv_2;

    @Override
    public int initLayout() {
        return R.layout.ac_intergra_account;
    }

    @Override
    public void initTitle() {

    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
        dialog = new LoadingDialog(IntegralAccountAc.this, 0);
    }

    @Override
    public void initData() {
        dialog.show();
        NetWorkUtil.getIntegral(new HttpUtils.HttpCallback() {
            @Override
            public void onSuccess(String data) {
                dialog.dismiss();
                final IntegralBean integralBean = MyGson.getInstance().fromJson(data, IntegralBean.class);
                tv_1.setText(integralBean.getData().getScore() + "");
                tv_2.setText(integralBean.getData().getCoupon() + "");
                ToastUtil.showToast(IntegralAccountAc.this,integralBean.getMsg());
            }

            @Override
            public void onError(String msg) {
                super.onError(msg);
                dialog.dismiss();
                ToastUtil.showToast(IntegralAccountAc.this,msg);
            }
        });
    }
}
